from django.http import HttpResponse
from django.shortcuts import render

# Create your views here.


def index(request):
    """
    测试页面首页
    :params request: HttpRequest, http请求
    :return: Response, 对请求的响应
    """

    # 尝试读取用户信息 当读取失败时返回None 此处直接使用 request.session["username"] 会报错
    username = request.session.get('username', None)
    if username is None:
        print("未发现用户信息")

        # 设置用户信息
        request.session["username"] = "zhangsan"
    else:
        print("发现用户信息" + username)

    return HttpResponse('success')
